dotConnect for SQLite Documentation
Devart.Data.SQLite Namespace / SQLiteDataReader Class / GetChars Method / GetChars(Int32,Int64,Char[],Int32,Int32) Method
The zero-based column ordinal.
The index within the field where the read operation is to begin.
The buffer into which to copy data.
The index within the buffer where the write operation is to begin.
The maximum number of characters to read.
Example

In This Topic
    GetChars(Int32,Int64,Char[],Int32,Int32) Method
    In This Topic
    Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.
    Syntax
    'Declaration
     
    Public Overloads Overrides Function GetChars( _
       ByVal i As Integer, _
       ByVal fieldOffset As Long, _
       ByVal buffer() As Char, _
       ByVal bufferOffset As Integer, _
       ByVal length As Integer _
    ) As Long
    public override long GetChars( 
       int i,
       long fieldOffset,
       char[] buffer,
       int bufferOffset,
       int length
    )

    Parameters

    i
    The zero-based column ordinal.
    fieldOffset
    The index within the field where the read operation is to begin.
    buffer
    The buffer into which to copy data.
    bufferOffset
    The index within the buffer where the write operation is to begin.
    length
    The maximum number of characters to read.

    Return Value

    The actual number of characters read.

    Remarks
    GetChars returns the number of available characters in the field. In most cases this is the exact length of the field. However, the number returned may be less than the true length of the field if GetChars has already been used to obtain characters from the field. This may be the case, for example, if the SQLiteDataReader is reading a large data structure into a buffer.

    If you pass a buffer that is a null value. GetChars returns the length of the field in characters.

    Example
    This sample shows how to read data from a field into array of chars.
    static void GetThatChars(SQLiteConnection sqConnection)
    {
      SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM Dept");
      cmd.Connection = sqConnection;
      sqConnection.Open();
      try
      {
        SQLiteDataReader reader = cmd.ExecuteReader();
        reader.Read();
        char[] myChars = new char[50];
        long bytesRead = reader.GetChars(reader.GetOrdinal("DName"),0,myChars,0,50);
        Console.WriteLine(bytesRead+ " bytes read from the table.");
        Console.WriteLine(myChars);
        reader.Close();
      }
      finally
      {
        sqConnection.Close();
      }
    }
    Public Sub GetThatChars(ByVal sqConnection As SQLiteConnection)
      Dim cmd As SQLiteCommand = New SQLiteCommand("SELECT * FROM Dept")
      cmd.Connection = sqConnection
      sqConnection.Open()
      Try
        Dim reader As SQLiteDataReader = cmd.ExecuteReader()
        reader.Read()
        Dim myChars(50) As Char
        Dim bytesRead As Long = reader.GetChars(reader.GetOrdinal("DName"), 0, myChars, 0, 50)
        Console.WriteLine(bytesRead & " bytes read from the table.")
        Console.WriteLine(myChars)
        reader.Close()
      Finally
        sqConnection.Close()
      End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also